﻿using DataConnector;
using Library;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LabManager 
{
    public partial class LoginForm : Form
    {
        public User User { get; set; }
        private SimpleAES simpleAES = new SimpleAES();

        public LoginForm()
        {
            InitializeComponent();
        }

        private void btLogin_Click(object sender, EventArgs e)
        {
            User = GetCurrentUser();

            Close();
        }

        private void btCancel_Click(object sender, EventArgs e)
        {
            Close();
        }

        private User GetCurrentUser()
        {
            string username = tbUsername.Text;
            string password = tbPassword.Text;

            var user = DataConnectorLayer.Instance.Login(username, simpleAES.EncryptToString(password));

            return user;
        }
    }
}
